from src.testbleu import calculate_bleu_from_a_folder
import os


def list_subdirectories(root_dir):
    subdirectories = [os.path.join(root_dir, d) for d in os.listdir(root_dir) if
                      os.path.isdir(os.path.join(root_dir, d))]
    for d in subdirectories:
        subdirectories.extend(list_subdirectories(d))
    return subdirectories


def calculate_bleu_from_a_day(day_path):
    total_data = {}
    exp_folder_list = list_subdirectories(day_path)
    for exp in exp_folder_list:
        exp_data = calculate_bleu_from_a_folder(exp)
        if exp_data:
            total_data[exp] = exp_data
        else:
            continue
    return total_data


if __name__ == '__main__':
    folder = r"C:\Users\31956\Downloads\24_02_10"
    data = calculate_bleu_from_a_day(folder)
    print(data)
